package springboot.controller;

import org.apache.shiro.authz.annotation.RequiresPermissions;
import springboot.domain.ReportRepair;
import springboot.domain.StudentReportRepair;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import springboot.service.ReportRepairService;

import java.util.Collection;

@RestController
@RequestMapping("/manger")
public class MangerController {
    @Autowired
    private ReportRepairService reportRepairService;
    @PostMapping("/ReportRepairAdd")
    @RequiresPermissions("ReportRepair:post")
    public String ReportRepairAdd(@RequestBody ReportRepair reportRepair) {
            reportRepairService.add(reportRepair);
        return "添加成功";
    }
    @DeleteMapping("/ReportRepairDelete/{id}")
    @RequiresPermissions("ReportRepair:delete")
    public String ReportRepairDelete(@PathVariable(name = "id")int id){
         reportRepairService.delete(id);
         return "删除成功";
    }
    @PutMapping("/ReportRepairUpdate")
    @RequiresPermissions("ReportRepair:put")
    public String ReportRepairUpdate(@RequestBody ReportRepair reportRepair){
        reportRepairService.update(reportRepair);
        return "修改成功";
    }
    @GetMapping(value={"/ReportRepairFindByDorm/{dorm}"})
    @RequiresPermissions("ReportRepair:get")
    public Collection<ReportRepair> ReportRepairFindByDorm(@PathVariable(name = "dorm")String dorm){
        return reportRepairService.find(dorm);
    }
    @PostMapping("/ReportRepairManagerAgreeReport")
    @RequiresPermissions("AgreeReport:post")
    public String ReportRepairManagerAgreeReport(@RequestBody StudentReportRepair studentReportRepair) {
        reportRepairService.managerAgreeReportRepair(studentReportRepair);
        return "同意此申请成功";
    }
    @PostMapping("/ReportRepairManagerDisAgreeReport")
    @RequiresPermissions("DisAgreeReport:post")
    public String ReportRepairManagerDisAgreeReport(@RequestBody StudentReportRepair studentReportRepair) {
         reportRepairService.managerDisAgreeReportRepair(studentReportRepair);
        return "不同意此申请成功";
    }
}
